home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / 4cmp22s.zip / EXCEPTIO.4TH < prev    next >
Text File  |  1994-10-30  |  976b  |  39 lines

  1. \ ANS Forth Exception Wordset
  2. \ Contents Copyright (C) 1994 by Thomas Almy
  3. \ Permission is granted to registered users of ForthCMP to sell or distribute
  4. \ computer programs incorporating the compiled contents of this file.
  5.  
  6. \ The return stack is used as the exception stack. 
  7. \ Information in the stack frame:
  8. \  Pointer to next frame  (top of frame-- lowest address)
  9. \  Saved SP
  10. \  Saved IP 
  11.  
  12. VARIABLE exfp    \ Exception frame pointer
  13.  
  14. CODE CATCH 
  15.   SI POP  AX POP  \ retAddr execAddr
  16.   BP DEC BP DEC SI [BP] MOV
  17.   BP DEC BP DEC SP [BP] MOV
  18.   BP DEC BP DEC exfp [] BX MOV  BX [BP] MOV
  19.   BP exfp [] MOV
  20.   AX CALLI
  21.   [BP] AX MOV  AX exfp [] MOV  
  22.   AX AX XOR  AX PUSH
  23.   4 +[BP] AX MOV  6 # BP ADD  
  24.   AX JMPI
  25. END-CODE
  26.  
  27. 1 0 IN/OUT
  28. CODE throw
  29.   exfp [] BP MOV [BP] BX MOV BX exfp [] MOV
  30.   2 +[BP] SP MOV  AX PUSH
  31.   4 +[BP] AX MOV
  32.   6 # BP ADD  AX JMPI
  33. END-CODE
  34.  
  35. : THROW  ?DUP IF exfp @ IF throw THEN
  36.        ." Uncaught THROW: " . BYE THEN ;
  37.  
  38.  
  39.